﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class SendEmailDAO : BaseService
    {
        public IList<SendEmail> GetListByPage(int page, int pagesize,string email)
        {
            string hql = "from SendEmail where 1=1 ";
            if (email != null && email.Trim().Length > 0)
            {
                hql += " and UserEmail like '%" + email + "%'";
            }
            hql += "  order by Id desc";
            return FindList<SendEmail>(hql, null, (page - 1) * pagesize, pagesize);
        }
        public int GetCount(string email)
        {
            string hql = "select count(*) from SendEmail where 1=1";
            if (email != null && email.Trim().Length > 0)
            {
                hql += " and UserEmail like '%" + email + "%'";
            }
            return Convert.ToInt32(GetValue(hql));
        }
        public bool IsExists(string email)
        {
            string hql = "select count(*) from SendEmail where UserEmail like'" + email + "'";
            int count = Convert.ToInt32(GetValue(hql));
            if (count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public IList<SendEmail> GetAll()
        {
            string hql = "from SendEmail";
            return FindList<SendEmail>(hql, null, null, null);
        }
        public bool InsertSendEmail(SendEmail email)
        {
            try {
                DBHelper.TransInsert(email);
                return true;
            }
            catch { return false; }
        }
    }
}
